﻿CREATE TABLE [dbo].[ProductOrderDetails] (
    [ID]         INT             IDENTITY (1, 1) NOT NULL,
    [OID]        INT             NOT NULL,
    [ProductID]  INT             NOT NULL,
    [MaterialID] INT             NOT NULL,
    [ProcessID]  INT             NOT NULL,
    [Size]       VARCHAR (50)    CONSTRAINT [DF_ProductOrderDetails_Size] DEFAULT ('无') NOT NULL,
    [Quantity]   DECIMAL (18, 5) NOT NULL,
    [CostMoney]  DECIMAL (18, 5) CONSTRAINT [DF_ProductOrderDetails_CostMoney] DEFAULT ((0)) NOT NULL,
    [Balance]    DECIMAL (18, 5) CONSTRAINT [DF_ProductOrderDetails_Balance] DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK__order_pr__3214EC271A14E395] PRIMARY KEY CLUSTERED ([ID] ASC),
    CONSTRAINT [FK_order_product_details_order_product] FOREIGN KEY ([OID]) REFERENCES [dbo].[ProductOrders] ([ID]) ON DELETE CASCADE,
    CONSTRAINT [FK_order_product_details_products] FOREIGN KEY ([ProductID]) REFERENCES [dbo].[Products] ([ID]),
    CONSTRAINT [FK_ProductOrderDetails_ProductMaterials] FOREIGN KEY ([MaterialID]) REFERENCES [dbo].[ProductMaterials] ([ID]),
    CONSTRAINT [FK_ProductOrderDetails_ProductProcesses] FOREIGN KEY ([ProcessID]) REFERENCES [dbo].[ProductProcesses] ([ID])
);





